﻿using System;

namespace Alex.Library.Log
{
    /// <summary>
    /// HTML格式日志模板
    /// </summary>
    public class HtmlContentTemplate : ILogInfoTemplate
    {
        private const string TEMP = "<html><head><title></title></head><body><h3>{title}</h3><h3>{level}</h3><p>{message}</p></body></html>";
        /// <summary>
        /// 模板内容
        /// </summary>
        public string Content
        {
            get { return TEMP; }            
        }
        /// <summary>
        /// 标题
        /// </summary>
        public string Title { get; set; }        

        /// <summary>
        /// 格式化数据
        /// </summary>
        /// <param name="level">级别</param>
        /// <param name="message">消息</param>
        /// <returns></returns>
        public string Format(LogLevel level, string message)
        {
            return TEMP.Replace("{title}", Title)
                       .Replace("{level}", level.ToString())
                       .Replace("{message}", message);
        }
    }
}
